package com.gw.detail.controllor.detail;

import java.util.List;

import com.gw.detail.domain.Crashper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gw.detail.service.ICrashperService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 乘员运动Controller
 * 
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/crashper")
public class CrashperController extends BaseController
{
    @Autowired
    private ICrashperService crashperService;

    /**
     * 查询乘员运动列表
     */
    @PreAuthorize("@ss.hasPermi('detail:crashper:list')")
    @GetMapping("/list")
    public TableDataInfo list(Crashper crashper)
    {
        startPage();
        List<Crashper> list = crashperService.selectCrashperList(crashper);
        return getDataTable(list);
    }

    /**
     * 导出乘员运动列表
     */
    @PreAuthorize("@ss.hasPermi('detail:crashper:export')")
    @Log(title = "乘员运动", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Crashper crashper)
    {
        List<Crashper> list = crashperService.selectCrashperList(crashper);
        ExcelUtil<Crashper> util = new ExcelUtil<Crashper>(Crashper.class);
        return util.exportExcel(list, "乘员运动数据");
    }

    /**
     * 获取乘员运动详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:crashper:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(crashperService.selectCrashperById(id));
    }

    /**
     * 新增乘员运动
     */
    @PreAuthorize("@ss.hasPermi('detail:crashper:add')")
    @Log(title = "乘员运动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Crashper crashper)
    {
        return toAjax(crashperService.insertCrashper(crashper));
    }

    /**
     * 修改乘员运动
     */
    @PreAuthorize("@ss.hasPermi('detail:crashper:edit')")
    @Log(title = "乘员运动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Crashper crashper)
    {
        return toAjax(crashperService.updateCrashper(crashper));
    }

    /**
     * 删除乘员运动
     */
    @PreAuthorize("@ss.hasPermi('detail:crashper:remove')")
    @Log(title = "乘员运动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crashperService.deleteCrashperByIds(ids));
    }
}
